﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Entity;
using System.Data;
using System.Data.SqlClient;
using DAL;

namespace BLL
{
    public class T_BLogin
    {
        //用户登入查询
        public static int Log(UserInfo us)
        {
            SqlDataReader dr = T_Login.Log(us);
            int power = 0;
            if (dr.Read())
            {
                while (dr.Read())
                {
                    power = (int)dr["UserPower"];
                }
                dr.Close();
                return power;
            }
            else
            {
                dr.Close();
                return 0;
            }
        }

        //用户注册
        public static bool Registered(UserInfo us)
        {
            return T_Login.Registered(us);
        }

        //用户名重复解决
        public static bool LogCheck(UserInfo us)
        {
            SqlDataReader dr = T_Login.LogCheck(us);
            if (dr.Read())
            {
                dr.Close();
                return false;
            }
            else
            {
                dr.Close();
                return true;
            }

        }

        //用户id查询
        public static int Logid(UserInfo us)
        {
            SqlDataReader dr = T_Login.Log(us);
            int id = 0;
            while (dr.Read())
            {
                id = (int)dr["UserId"];
            }
            dr.Close();
            return id;
        }

    }
}
